#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @Time: 2022/12/22 11:16
# @Author: scg
# @Email: xxx@gmail.com
# @File：product_add_page.py

from selenium.webdriver.common.by import By
from pages.base_page import BasePage


class ProductAddPage(BasePage):
    url = '/crm/index.php?m=product&a=add'

    name_locator = (By.ID, 'name')
    development_time_locator = (By.ID, 'development_time')
    development_team_locator = (By.ID, 'development_team')
    main_pic_locator = (By.ID, 'main_pic')
    save_btn_locator = (By.CSS_SELECTOR, '#form1 > table > tfoot > tr > td > input:nth-child(1)')

    def input_name(self, name):
        self.driver.find_element(*self.name_locator).send_keys(name)

    def input_development_time(self, time):
        # 2022-12-22
        self.driver.find_element(*self.development_time_locator).send_keys(time)

    def input_development_team(self, team):
        self.driver.find_element(*self.development_team_locator).send_keys(team)

    def input_main_pic(self, img):
        self.driver.find_element(*self.main_pic_locator).send_keys(img)

    def click_save_btn(self):
        self.driver.find_element(*self.save_btn_locator).click()
